package com.iclub.controller;

import java.io.IOException;
import java.util.HashMap;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import com.alibaba.fastjson.JSON;
import com.iclub.model.ActiveInfo;
import com.iclub.model.SignUpInfo;

/**
 *
 */
@Controller
@RequestMapping("/active")
public class ActiveInfoController extends BaseController{

	@RequestMapping("/insertActiveInfo.do")
	public void insertActiveInfo(HttpServletRequest request,
			HttpServletResponse response, ActiveInfo activeInfo)
			throws IOException {
		log_detail.info("���붯̬��Ϣʧ��" + activeInfo);
		Map<String, Object> res = activeInfoServiceImpl
				.insertActiveInfo(activeInfo);
		String json = JSON.toJSONString(res);
		log_detail.info("��Ӧ�����"+ json);
		response.setCharacterEncoding("utf-8");
		response.getWriter().write(json);
	}

	@RequestMapping("/insertSignupInfo.do")
	public void insertSignupInfo(HttpServletRequest request,
			HttpServletResponse response, SignUpInfo signUpInfo)
			throws IOException {
		log_detail.info("�û�ǩ����Ϣ��"+ signUpInfo);
		Map<String, Object> res = activeInfoServiceImpl
				.insertSignupInfo(signUpInfo);
		String json = JSON.toJSONString(res);
		log_detail.info("�û�ǩ�������" + json);
		response.setCharacterEncoding("utf-8");
		response.getWriter().write(json);
	}

	@RequestMapping("/getActiveInfoDetail.do")
	public void selectActiveInfo(HttpServletRequest request,
			HttpServletResponse response, String activeId) throws IOException {
		log_detail.info("��ȡ��̬��Ϣ����"+ activeId);
		Map<String, Object> res = activeInfoServiceImpl
				.selectActiveInfo(Integer.parseInt(activeId));
		String json = JSON.toJSONString(res);
		log_detail.info("��Ӧ�����"+ json);
		response.setCharacterEncoding("utf-8");
		response.getWriter().write(json);
	}

	@RequestMapping("/getInviteInfoList.do")
	public void getInviteInfoList(HttpServletRequest request,
			HttpServletResponse response, String userId) throws IOException {
		Map<String, Object> req = new HashMap<String, Object>();
		req.put("userId", userId);
		req.put("activetype", 0);
		log_detail.info("��ȡ��Լ��Ϣ�б�"+ req);
		Map<String, Object> res = activeInfoServiceImpl
				.selectActiveInfoList(req);
		String json = JSON.toJSONString(res);
		log_detail.info("��Ӧ�����"+ json);
		response.setCharacterEncoding("utf-8");
		response.getWriter().write(json);
	}


	@RequestMapping("/getDiaryInfoList.do")
	public void getDiaryInfoList(HttpServletRequest request,
			HttpServletResponse response, String userId) throws IOException {
		Map<String, Object> req = new HashMap<String, Object>();
		req.put("userId", userId);
		req.put("activetype", 2);
		log_detail.info("��ȡ��Ϣ"+ req);
		Map<String, Object> res = activeInfoServiceImpl
				.selectActiveInfoList(req);
		String json = JSON.toJSONString(res);
		log_detail.info("��Ӧ�����"+ json);
		response.setCharacterEncoding("utf-8");
		response.getWriter().write(json);
	}

}
